package StudyCode.summary.myfile;

import java.io.UnsupportedEncodingException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ConvertAsciiToByteArray {
	public static void main(String[] argv) throws Exception {
		String string = "www.tah1986.com";
		System.out.println(string + "转为字节数组:");
		System.out.println(java.util.Arrays.toString(asciiStringToByteArray(string)));
	}

	private static byte[] asciiStringToByteArray(String string) {
		byte[] bytes = null;
		try {
			bytes = string.getBytes("US-ASCII");
		} catch (UnsupportedEncodingException ex) {
			ex.printStackTrace();
		}
		return bytes;
	}
}
